<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/react.development.js"></script>
    <script src="js/react-dom.development.js"></script>
    <script src="js/babel.js"></script>
    <style>
        dl {
            margin: 0;
        }
        .friend-list {
            border: 1px solid #000000;
            width: 200px;
        }
        .friend-group dt {
            padding: 10px;
            background-color: rgb(64, 158, 255);
            font-weight: bold;
        }
        .friend-group dd {
            padding: 10px;
            display: -none;
        }
        .friend-group.expanded dd {
            display: block;
        }
        .friend-group dd.checked {
            background: green;
        }
    </style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
let datas = {
    family: {
        title: '家人',
        list: [
            {name: '爸爸'},
            {name: '妈妈'}
        ]
    },
    friend: {
        title: '朋友',
        list: [
            {name: '张三'},
            {name: '李四'},
            {name: '王五'}
        ]
    },
    customer: {
        title: '客户',
        list: [
            {name: '阿里'},
            {name: '腾讯'},
            {name: '头条'}
        ]
    }
};
function Dl(props){
    // console.log(props);
    let {data} = props;
    return (
        <dl className="friend-group">
            <dt>{data.title}</dt>
            {
                data.list.map((item,index)=>{
                    return <dd key={index}>{item.name}</dd>
                })
            }
        </dl>
    );
}
function FriendList() {
    return (
        <div className="friend-list">
            {Object.keys(datas).map(item=>{
                return <Dl 
                    key={item} 
                    data={datas[item]}
                    name = {item}
                />;
            })}
        </div>
    );
}
ReactDOM.render(
    <FriendList />, 
    document.querySelector("#root")
);
</script>      
</body>
</html>